package com.cxg.fairy.ec.main.personal.settings;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.SimpleClickListener;
import com.cxg.fairy.app.AccountManager;
import com.cxg.fairy.delegates.LatteDelegate;
import com.cxg.fairy.ec.main.EcBottomDelegate;
import com.cxg.fairy.ec.main.personal.list.ListBean;
import com.cxg.fairy.ec.sign.SignInDelegate;
import com.cxg.fairy.util.storage.LattePreference;

/**
 * Created by CFairy
 */

public class SettingsClickListener extends SimpleClickListener {

    public static final String POST_ORDER_NAME_TEL = "POST_ORDER_NAME_TEL";

    public static final String POST_ORDER_ADDRESS = "POST_ORDER_ADDRESS";

    public static final String POST_ORDER_ADDRESS_ID = "POST_ORDER_ADDRESS_ID";

    public static final String POST_ORDER_COUPON_NO = "POST_ORDER_COUPON_NO";

    private final LatteDelegate DELEGATE;

    public SettingsClickListener(LatteDelegate delegate) {
        this.DELEGATE = delegate;
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        final ListBean bean = (ListBean) baseQuickAdapter.getData().get(position);
        int id = bean.getId();
        switch (id) {
            case 1:
                //这是消息推送的
                break;
            case 2:
                DELEGATE.getSupportDelegate().start(bean.getDelegate());
                break;
            case 4:
                //退出帐户
                DELEGATE.getSupportDelegate().pop();
                DELEGATE.getSupportDelegate().start(new SignInDelegate());
                AccountManager.setSignState(false);
                LattePreference.removeCustomAppProfile(POST_ORDER_NAME_TEL);
                LattePreference.removeCustomAppProfile(POST_ORDER_ADDRESS);
                LattePreference.removeCustomAppProfile(POST_ORDER_ADDRESS_ID);
                LattePreference.removeCustomAppProfile(POST_ORDER_COUPON_NO);
                break;
            case 5:
                DELEGATE.getSupportDelegate().start(bean.getDelegate());
                break;
            case 6:
                DELEGATE.getSupportDelegate().start(bean.getDelegate());
                break;
            case 7:
                DELEGATE.getSupportDelegate().start(bean.getDelegate());
                break;
            default:
                break;
        }
    }

    @Override
    public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) {

    }

    @Override
    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {

    }

    @Override
    public void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {

    }
}
